<template>
	<view>
		<view class="px-3 main-bg-color position-relative" style="height: 150upx;">
			<view class="row main-text-color-bai a-center j-sb" style="height: 100upx;">
				<view class="row a-center" style="height: 126upx;">
					<view class="pl-2">
						<view class="store">
							{{items.store_name}}
						</view>
						<view class="">
							{{items.address}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<view>
			<view class="p-3">
				<view class="row j-sb a-center p-2" style="height: 88upx;border: 1upx solid #f6f6f6;border-radius:5upx;">
					<input @input="inputChange" @confirm="search()" type="text" placeholder="请输入订单号" placeholder-style="color:#999999;" />
					<image @tap="search()" src="../../static/search.jpg" style="width: 50upx;height: 52upx;"></image>
				</view>
			</view>
		</view>
		
		<block v-for="(item,index) in ordersList" :key="index">
			<view style="width:750upx;height:20upx;background-color:#f4f4f4;"></view>
			<view class="lists">
				<view class="list_order">
					订单编号：{{item.ordernosub}}
				</view>
				<view class="list_content">
					<image :src="baseUrl+item.img"></image>
					<view class="list_info">
						<view class="list_title">{{item.title}}</view>
						<view class="list_type">{{item.params}}</view>
						<view class="list_price">￥{{item.price}}</view>
					</view>
				</view>
				<view class="list_times">
					<view class="list_time">{{item.time}}</view>
					<view class="list_button" @tap="detail(item.id)">查看明细</view>
				</view>
			</view>
		</block>
		
		<view style="width:750upx;height:20upx;background-color:#f4f4f4;"></view>
	</view>
</template>

<script>
	import request from '@/common/lib/request.js'
	export default {
		data() {
			return {
				page:1,
				baseUrl:request.common.baseUrl,
				ordersList:[],
				items:'',
				keyword:''
			}
		},
		onLoad:function(option){
			console.log(option)
			this.items=option
			// uni.showToast({
			// 	title: '请输入订单号查询',
			// 	icon: 'success',
			// 	duration: 2000
			// });
			uni.request({
			    url: request.common.baseUrl+'/api/agent/storeOrder',
			    data: {
					page:this.page,
					store_id:option.id,
					// fromtime:'',
					// totime:'',
					keyword:this.keyword
				},
			    header: {
					'Content-Type':'application/json;charset=UTF-8',
					'Content-Type':'application/x-www-form-urlencoded'
			    },
			    success: (res) => {
						if(res.data.code==200){
							this.ordersList=res.data.data
						}else{
							uni.showToast({
							    title: '暂无数据',
								icon: 'success',
							    duration: 2000
							});
						}
			    }
			});
		},
		methods: {
			inputChange: function (e) {
				this.keyword=e.detail.value
			},
			search:function(){
				this.page=1
				uni.request({
				    url: request.common.baseUrl+'/api/agent/storeOrder',
				    data: {
						page:this.page,
						store_id:this.items.id,
						// fromtime:'',
						// totime:'',
						keyword:this.keyword
					},
				    header: {
						'Content-Type':'application/json;charset=UTF-8',
						'Content-Type':'application/x-www-form-urlencoded'
				    },
				    success: (res) => {
						this.ordersList=[]
				        if(res.data.code==200){
							this.ordersList=res.data.data
						}else{
							uni.showToast({
							    title: '暂无数据',
								icon: 'none',
							    duration: 2000
							});
						}
				    }
				});
			},
			detail(id){
				uni.navigateTo({
					url:'/pages/agent/verificationdetail?id='+id+'&store_name='+this.items.store_name+'&address='+this.items.address
				})
			}
		},
		onReachBottom:function(){
			this.page=this.page+1;
			if(this.keyword){
				uni.request({
				    url: request.common.baseUrl+'/api/agent/storeOrder',
				    data: {
						page:this.page,
						store_id:this.items.id,
						// fromtime:'',
						// totime:'',
						keyword:this.keyword
					},
				    header: {
						'Content-Type':'application/json;charset=UTF-8',
						'Content-Type':'application/x-www-form-urlencoded'
				    },
				    success: (res) => {
				        if(res.data.code==200){
							for (var j = 0; j < res.data.data.length; j++) {
								this.ordersList.push(res.data.data[j])
							}
						}else{
							uni.showToast({
							    title: '暂无数据',
								icon: 'none',
							    duration: 2000
							});
						}
				    }
				});
			}else{
				uni.request({
				    url: request.common.baseUrl+'/api/agent/storeOrder',
				    data: {
				    	page:this.page,
				    	store_id:this.items.id,
				    	// fromtime:'',
				    	// totime:'',
				    	keyword:this.keyword
				    },
				    header: {
						'Content-Type':'application/json;charset=UTF-8',
						'Content-Type':'application/x-www-form-urlencoded'
				    },
				    success: (res) => {
				        if(res.data.code==200){
							for (var j = 0; j < res.data.data.length; j++) {
								this.ordersList.push(res.data.data[j])
							}
						}else{
							uni.showToast({
							    title: '暂无数据',
								icon: 'none',
							    duration: 2000
							});
						}
				    }
				});
			}
			
		}
	}
</script>

<style>
.store{
	font-size:34upx;
	width:600upx;
	overflow:hidden;
	text-overflow:ellipsis;
	white-space:nowrap;
}
.lists{
	width:650upx;
	height:280upx;
	margin:0 50upx;
}
.list_order{
	width:650upx;
	height:70upx;
	line-height:70upx;
	color:#999999;
}
.list_content{
	width:650upx;
	height:150upx;
}
.list_content image{
	width:180upx;
	height:120upx;
	float:left;
}
.list_info{
	float:left;
	margin-left:25upx;
}
.list_title{
	width:440upx;
	font-size:28upx;
	overflow:hidden;
	text-overflow:ellipsis;
	white-space:nowrap;
}
.list_type{
	width:440upx;
	overflow:hidden;
	text-overflow:ellipsis;
	white-space:nowrap;
	font-size:24upx;
	color:#999999;
}
.list_price{
	font-size:28upx;
	color:#ff6101;
}
.list_times{
	height:60upx;
}
.list_time{
	float:left;
	font-size:20upx;
	color:#999999;
}
.list_button{
	float:right;
	font-size:24upx;
	color:#666666;
	border:1upx solid #f6f6f6;
	padding:0 15upx;
	border-radius:25upx;
}
</style>
